import axios from 'axios'

const requestAxios = axios.create({
  baseURL: 'http://interview-api-t.itheima.net',
  timeout: 5000
})

requestAxios.interceptors.request.use(
  config => {
    // 在发送请求之前做些什么
    config.headers.Authorization = 'Bearer ' + localStorage.getItem('userToken')
    return config
  },
  error => {
    // 对请求错误做些什么
    return Promise.reject(error)
  }
)

export default requestAxios
